#include "../iBe.h"
#include <math.h>

Track::Track()
{}

Track::~Track()
{}

void Track::update(const UINT64 &_time)
{
  internalUpdate(_time);
}

const Turple3f& Track::getValue() const
{
  return currValue;
}

void Track::setDuration(const UINT64 &_dur)
{
  duration = _dur;
}

CircularTrack::CircularTrack():radius(1)
{
  Turple1f startAngle, endAngle;

  startAngle[0] = 0;
  endAngle[0]   = 2 * PI;

  angle.setStartEndValue(startAngle, endAngle);
}

CircularTrack::~CircularTrack()
{}

void CircularTrack::internalUpdate(const UINT64 &_time)
{
  Turple1f ang;
  angle.update(_time);
  ang = angle.getValue();

  currValue[0] = radius * sin(ang[0]);
  currValue[1] = radius * cos(ang[0]);
  currValue[2] = 0;
}

void CircularTrack::setLoop(const bool &_loop)
{
  angle.setLoop(_loop);
}

void CircularTrack::setStartEndTime(const UINT64 &_start, const UINT64 &_end)
{
  angle.setStartEndTime(_start, _end);
}

void CircularTrack::start(const UINT64 &_time)
{
  angle.setStartEndTime(_time, _time + duration);
}

void CircularTrack::setRadius(float _radius)
{
  radius = _radius;
}
